using UnityEngine;
using System.Collections;

[RequireComponent(typeof(MeshFilter))]
public class TempMesh : MonoBehaviour {

    public float width = 51.2f;
    public float height = 12.8f;

    MeshFilter mf;

	// Use this for initialization
	void Start () {
        //Debug.Log("start");
        Vector3[] verts = new Vector3[4];
        Vector3[] normals = new Vector3[4];
        Vector2[] uv = new Vector2[4];
        int[] tri = new int[6];

        //Debug.Log("gameObject : "+gameObject);
        mf = GetComponent<MeshFilter>();
        
        

        verts[0] = new Vector3(-width / 2, 0, -height / 2);
        verts[1] = new Vector3(width / 2, 0, -height / 2);
        verts[2] = new Vector3(-width / 2, 0, height / 2);
        verts[3] = new Vector3(width / 2, 0, height / 2);

        for (int i = 0; i < normals.Length; i++)
        {
            normals[i] = Vector3.up;
        }

        uv[0] = new Vector2(0, 0);
        uv[1] = new Vector2(1, 0);
        uv[2] = new Vector2(0, 1);
        uv[3] = new Vector2(1, 1);

        tri[0] = 0;
        tri[1] = 2;
        tri[2] = 3;
        tri[3] = 0;
        tri[4] = 3;
        tri[5] = 1;

        Mesh mesh = new Mesh();

        mesh.vertices = verts;
        mesh.triangles = tri;
        mesh.uv = uv;
        mesh.normals = normals;

        mf.mesh = mesh;

        //gameObject.AddComponent<MeshRenderer>();
        //renderer.material = new Material(Shader.Find("Transparent/Diffuse"));
	}
	
	
}
